package com.bocloud.cmp.entity.resource;

import java.util.Date;
import java.util.List;

import org.springframework.format.annotation.DateTimeFormat;

import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Table("host_system")
public class HostSystem extends GenericEntity {

	@PK(value = PKStrategy.AUTO)
	private Long id;
	@Column("uuid")
	private String uuid;
	@Column("vendor_id")
	private Long vendorId; // 云供应商ID
	@IgnoreAll
	private String vendorName; // 云供应商名称
	@Column("gmt_expired")
	@JsonSerialize(using = DateSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date gmtExpired;// 过期时间
	@Column("cpu_num")
	private Integer cpuNum;// 宿主机（物理机）cpu核数
	@Column("cpu_total")
	private Long cpuTotal;
	@Column("mem_total")
	private Long memTotal;
	@Column("disk_total")
	private Long diskTotal;
	@Column("cpu_used")
	private Long cpuUsed;
	@Column("mem_used")
	private Long memUsed;
	@Column("disk_used")
	private Long diskUsed;
	@Column("vdc_id")
	private Long vdcId;
	@Column("cluster_id")
	private Long clusterId;
	@Column("category")
	private String category;
	@Column("catalog")
	private String catalog;
	@Column("cpu_model")
	private String cpuModel;
	@Column("vendor")
	private String vendor;
	@IgnoreAll
	private List<String> stores;
	@IgnoreAll
	private List<CloudServer> servers;// 虚拟机
	@IgnoreAll
	private String clusterName;// 所在集群的名称
	@IgnoreAll
	private String vdcName;// 所在数据中心的名称
	@IgnoreAll
	private List<NetworkCard> netcards;
	@Column("vm_num")
	private Integer vmNum;// 宿主机（物理机）上的虚拟机数量
	@Column("template_num")
	private Integer templateNum;// 宿主机（物理机）上的虚拟机数量
	@Column("power_state")
	private String powerState;// 宿主机（物理机）电源状态
	@Column("datastore_num")
	private Integer datastoreNum;// 宿主机（物理机）数据存储数量
	@Column("cpu_core")
	private Integer cpuCore;// 宿主机（物理机）cpu数量
	@Column("host_ip")
	private String hostIp;// 宿主机IP
	@Column("maintain")
	private boolean maintain;
	@Column("connected")
	private boolean connected;
	@IgnoreAll
	private List<DataStore> dataStores;
	@IgnoreAll
	private List<String> networks;

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the uuid
	 */
	public String getUuid() {
		return uuid;
	}

	/**
	 * @param uuid
	 *            the uuid to set
	 */
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	/**
	 * @return the vendorId
	 */
	public Long getVendorId() {
		return vendorId;
	}

	/**
	 * @param vendorId
	 *            the vendorId to set
	 */
	public void setVendorId(Long vendorId) {
		this.vendorId = vendorId;
	}

	/**
	 * @return the vendorName
	 */
	public String getVendorName() {
		return vendorName;
	}

	/**
	 * @param vendorName
	 *            the vendorName to set
	 */
	public void setVendorName(String vendorName) {
		this.vendorName = vendorName;
	}

	/**
	 * @return the gmtExpired
	 */
	public Date getGmtExpired() {
		return gmtExpired;
	}

	/**
	 * @param gmtExpired
	 *            the gmtExpired to set
	 */
	public void setGmtExpired(Date gmtExpired) {
		this.gmtExpired = gmtExpired;
	}

	/**
	 * @return the cpuNum
	 */
	public Integer getCpuNum() {
		return cpuNum;
	}

	/**
	 * @param cpuNum
	 *            the cpuNum to set
	 */
	public void setCpuNum(Integer cpuNum) {
		this.cpuNum = cpuNum;
	}

	/**
	 * @return the cpuTotal
	 */
	public Long getCpuTotal() {
		return cpuTotal;
	}

	/**
	 * @param cpuTotal
	 *            the cpuTotal to set
	 */
	public void setCpuTotal(Long cpuTotal) {
		this.cpuTotal = cpuTotal;
	}

	/**
	 * @return the memTotal
	 */
	public Long getMemTotal() {
		return memTotal;
	}

	/**
	 * @param memTotal
	 *            the memTotal to set
	 */
	public void setMemTotal(Long memTotal) {
		this.memTotal = memTotal;
	}

	/**
	 * @return the diskTotal
	 */
	public Long getDiskTotal() {
		return diskTotal;
	}

	/**
	 * @param diskTotal
	 *            the diskTotal to set
	 */
	public void setDiskTotal(Long diskTotal) {
		this.diskTotal = diskTotal;
	}

	/**
	 * @return the cpuUsed
	 */
	public Long getCpuUsed() {
		return cpuUsed;
	}

	/**
	 * @param cpuUsed
	 *            the cpuUsed to set
	 */
	public void setCpuUsed(Long cpuUsed) {
		this.cpuUsed = cpuUsed;
	}

	/**
	 * @return the memUsed
	 */
	public Long getMemUsed() {
		return memUsed;
	}

	/**
	 * @param memUsed
	 *            the memUsed to set
	 */
	public void setMemUsed(Long memUsed) {
		this.memUsed = memUsed;
	}

	/**
	 * @return the diskUsed
	 */
	public Long getDiskUsed() {
		return diskUsed;
	}

	/**
	 * @param diskUsed
	 *            the diskUsed to set
	 */
	public void setDiskUsed(Long diskUsed) {
		this.diskUsed = diskUsed;
	}

	/**
	 * @return the vdcId
	 */
	public Long getVdcId() {
		return vdcId;
	}

	/**
	 * @param vdcId
	 *            the vdcId to set
	 */
	public void setVdcId(Long vdcId) {
		this.vdcId = vdcId;
	}

	/**
	 * @return the clusterId
	 */
	public Long getClusterId() {
		return clusterId;
	}

	/**
	 * @param clusterId
	 *            the clusterId to set
	 */
	public void setClusterId(Long clusterId) {
		this.clusterId = clusterId;
	}

	/**
	 * @return the category
	 */
	public String getCategory() {
		return category;
	}

	/**
	 * @param category
	 *            the category to set
	 */
	public void setCategory(String category) {
		this.category = category;
	}

	/**
	 * @return the catalog
	 */
	public String getCatalog() {
		return catalog;
	}

	/**
	 * @param catalog
	 *            the catalog to set
	 */
	public void setCatalog(String catalog) {
		this.catalog = catalog;
	}

	/**
	 * @return the cpuModel
	 */
	public String getCpuModel() {
		return cpuModel;
	}

	/**
	 * @param cpuModel
	 *            the cpuModel to set
	 */
	public void setCpuModel(String cpuModel) {
		this.cpuModel = cpuModel;
	}

	/**
	 * @return the vendor
	 */
	public String getVendor() {
		return vendor;
	}

	/**
	 * @param vendor
	 *            the vendor to set
	 */
	public void setVendor(String vendor) {
		this.vendor = vendor;
	}

	/**
	 * @return the stores
	 */
	public List<String> getStores() {
		return stores;
	}

	/**
	 * @param stores
	 *            the stores to set
	 */
	public void setStores(List<String> stores) {
		this.stores = stores;
	}

	/**
	 * @return the servers
	 */
	public List<CloudServer> getServers() {
		return servers;
	}

	/**
	 * @param servers
	 *            the servers to set
	 */
	public void setServers(List<CloudServer> servers) {
		this.servers = servers;
	}

	/**
	 * @return the clusterName
	 */
	public String getClusterName() {
		return clusterName;
	}

	/**
	 * @param clusterName
	 *            the clusterName to set
	 */
	public void setClusterName(String clusterName) {
		this.clusterName = clusterName;
	}

	/**
	 * @return the vdcName
	 */
	public String getVdcName() {
		return vdcName;
	}

	/**
	 * @param vdcName
	 *            the vdcName to set
	 */
	public void setVdcName(String vdcName) {
		this.vdcName = vdcName;
	}

	/**
	 * @return the vmNum
	 */
	public Integer getVmNum() {
		return vmNum;
	}

	/**
	 * @param vmNum
	 *            the vmNum to set
	 */
	public void setVmNum(Integer vmNum) {
		this.vmNum = vmNum;
	}

	/**
	 * @return the templateNum
	 */
	public Integer getTemplateNum() {
		return templateNum;
	}

	/**
	 * @param templateNum
	 *            the templateNum to set
	 */
	public void setTemplateNum(Integer templateNum) {
		this.templateNum = templateNum;
	}

	/**
	 * @return the powerState
	 */
	public String getPowerState() {
		return powerState;
	}

	/**
	 * @param powerState
	 *            the powerState to set
	 */
	public void setPowerState(String powerState) {
		this.powerState = powerState;
	}

	/**
	 * @return the datastoreNum
	 */
	public Integer getDatastoreNum() {
		return datastoreNum;
	}

	/**
	 * @param datastoreNum
	 *            the datastoreNum to set
	 */
	public void setDatastoreNum(Integer datastoreNum) {
		this.datastoreNum = datastoreNum;
	}

	/**
	 * @return the cpuCore
	 */
	public Integer getCpuCore() {
		return cpuCore;
	}

	/**
	 * @param cpuCore
	 *            the cpuCore to set
	 */
	public void setCpuCore(Integer cpuCore) {
		this.cpuCore = cpuCore;
	}

	/**
	 * @return the hostIp
	 */
	public String getHostIp() {
		return hostIp;
	}

	/**
	 * @param hostIp
	 *            the hostIp to set
	 */
	public void setHostIp(String hostIp) {
		this.hostIp = hostIp;
	}

	/**
	 * @return the netcards
	 */
	public List<NetworkCard> getNetcards() {
		return netcards;
	}

	/**
	 * @param netcards
	 *            the netcards to set
	 */
	public void setNetcards(List<NetworkCard> netcards) {
		this.netcards = netcards;
	}

	/**
	 * @return the maintain
	 */
	public boolean isMaintain() {
		return maintain;
	}

	/**
	 * @param maintain
	 *            the maintain to set
	 */
	public void setMaintain(boolean maintain) {
		this.maintain = maintain;
	}

	/**
	 * @return the connected
	 */
	public boolean isConnected() {
		return connected;
	}

	/**
	 * @param connected
	 *            the connected to set
	 */
	public void setConnected(boolean connected) {
		this.connected = connected;
	}

	/**
	 * @param createrId
	 * @param ownerId
	 * @param menderId
	 * @param id
	 * @param uuid
	 * @param vendorId
	 * @param vendorName
	 * @param gmtExpired
	 * @param cpuTotal
	 * @param memTotal
	 * @param diskTotal
	 * @param cpuUsed
	 * @param memUsed
	 * @param diskUsed
	 */
	public HostSystem(Long createrId, Long ownerId, Long menderId, Long id, String uuid, Long vendorId,
			String vendorName, Date gmtExpired, Long cpuTotal, Long memTotal, Long diskTotal, Long cpuUsed,
			Long memUsed, Long diskUsed, String clusterName, Integer vmNum, String powerState, Integer datastoreNum,
			Integer cpuCore, Integer cpuNum) {
		super(createrId, ownerId, menderId);
		this.id = id;
		this.uuid = uuid;
		this.vendorId = vendorId;
		this.vendorName = vendorName;
		this.gmtExpired = gmtExpired;
		this.cpuTotal = cpuTotal;
		this.memTotal = memTotal;
		this.diskTotal = diskTotal;
		this.cpuUsed = cpuUsed;
		this.memUsed = memUsed;
		this.diskUsed = diskUsed;
		this.clusterName = clusterName;
		this.vmNum = vmNum;
		this.powerState = powerState;
		this.datastoreNum = datastoreNum;
		this.cpuCore = cpuCore;
		this.cpuNum = cpuNum;
	}

	/**
	 * 
	 */
	public HostSystem() {
		super();
	}

	public HostSystem(Long createrId, Long ownerId, Long menderId, String name, String status, Boolean deleted,
			String props, String remark) {
		super(createrId, ownerId, menderId, name, status, deleted, props, remark);
	}

	public HostSystem(Long createrId, Long ownerId, Long menderId) {
		super(createrId, ownerId, menderId);
	}

	/**
	 * @return the dataStores
	 */
	public List<DataStore> getDataStores() {
		return dataStores;
	}

	/**
	 * @param dataStores
	 *            the dataStores to set
	 */
	public void setDataStores(List<DataStore> dataStores) {
		this.dataStores = dataStores;
	}

	/**
	 * @return the networks
	 */
	public List<String> getNetworks() {
		return networks;
	}

	/**
	 * @param networks
	 *            the networks to set
	 */
	public void setNetworks(List<String> networks) {
		this.networks = networks;
	}

	public void preSave(Long createrId, Long menderId, Long vendorId, Long vdcId, Long clusterId) {
		this.setCreaterId(createrId);
		this.setMenderId(menderId);
		this.setVendorId(vendorId);
		this.setVdcId(vdcId);
		this.setClusterId(clusterId);
	}

}
